<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ include file="../include.jsp" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  	<meta http-equiv="Content-Type" content="multipart/form-data; charset=utf-8" />
    <title>质检</title>
    <script type="text/javascript">
    	 $(function(){
    		$("#dg").datagrid({    
			    url:'<%=path%>/releaseTask/findAllByType?type=1&state=4',
				method:"get",
			    columns:[[
			        {field:'taskName',title:'任务名称',width:100,align:'center'},
                    {field:'time',title:'发布时间',width:120,align:'center'},
                    {field:'url',title:'发布路径',width:400,align:'center'},
                    {field:'state',title:'状态',width:100,align:'center',formatter: function(v,r,i){return statusTask(v);}},
                    {field:'users',title:'任领人',width:100,align:'center',formatter: function(v,r,i){return r.users==null?"":(r.users.userName==null?"":r.users.userName);}},
                    {field:'updateUrl',title:'任领人发布',width:400,align:'center'},
                    {field:'updateTime',title:'任领人发布时间',width:120,align:'center'},
                    {field:'remark',title:'备注信息',width:100,align:'center'},
					{field:'isOk',title:'是否合格',width:100,align:'center'}
			    ]],
			    pagination:true,//底部显示分页组件 
			    singleSelect:true,//设置单选
			    toolbar: [{
					iconCls: 'icon-add',
					text:'提交的建筑物任务列表',
					// handler: function(){
					// 	//当点击添加时,让隐藏的对话框弹出
					// 	$("#dd").dialog("open");
					// }
				}]
			});
			/****************************************发布任务操作*******************************************************/
			//给保存免险弹出框的关闭按钮添加单击事件
			$("#saveCloseBtn").click(function(){
				//当点击添加时,话框关闭
				$("#dd").dialog("close");
			});
			//给保存发布任务弹出框的保存按钮添加单击事件
			$("#saveBtn").click(function(){
				var formData = new FormData();
				if ($('#uploadFile')[0].files[0] == null) {
					$.messager.show({title:'我的消息', msg:"请先选择要发布的文件", timeout:3000, showType:'slide'});
					return false;
				}
				var taskName=$('#taskName').val();
				if (taskName== null || taskName=="") {
					$.messager.show({title:'我的消息', msg:"请输入发布任务名称", timeout:3000, showType:'slide'});
					return false;
				}
				var remark=$('#remark').val();
				if (remark== null || remark=="") {
					$.messager.show({title:'我的消息', msg:"请输入发布任务备注信息", timeout:3000, showType:'slide'});
					return false;
				}
				formData.append('uploadFile', $('#uploadFile')[0].files[0]);
				formData.append('taskName', taskName);
				formData.append('remark', $('#remark').val());
				formData.append('type', 1);
				$.ajax({
					// enctype: 'multipart/form-data',
					type: 'POST',
					cache: false,
					url: '<%=path%>/releaseTask/uploadTask',
					// data: {taskName:taskName,remark:remark,uploadFile:uploadFile,type:type},
					data: formData,
					processData: false,
					contentType: false,
					dataType: "json",
					success: function(result) {
						$.messager.show({title:'我的消息', msg:result.msg, timeout:3000, showType:'slide'});
						if(result.flag==true){$("#dd").dialog("close");$("#dg").datagrid("reload");}
					}
				});
			});
		   /****************************************发布任务操作*******************************************************/
    	
    	 });
    </script>
  </head>
  
  <body>
    <table id="dg"></table>
  </body>
</html>
